﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RSFrame.Services
{
    /// <summary>
    /// 数据库访问服务
    /// </summary>
    public interface IDBService
    {
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        string ConnectionString { get; set; }

        /// <summary>
        /// 更新连接字符串
        /// </summary>
        /// <param name="parameters">更新参数</param>
        void UpdateConnectionString(params string[] parameters);

        /// <summary>
        /// 建立数据库连接
        /// </summary>
        /// <param name="connectionString">数据库连接字符串</param>
        /// <returns></returns>
        DbConnection EstablishConnection(string connectionString);
        DbConnection EstablishConnection();
        void CloseConnection(DbConnection connection);
        DbCommand GetCommand(string queryText, Dictionary<string, object> paraList);
        DbDataReader ReadData(DbConnection connection, DbCommand command);
        DbDataReader ReadData(DbConnection connection, string queryText, Dictionary<string, object> paraList);
        int WriteData(DbConnection connection, DbCommand command);
        int WriteData(DbConnection connection, string queryText, Dictionary<string, object> paraList);
        object AddData(DbConnection connection, DbCommand command);
        object AddData(DbConnection connection, string queryText, Dictionary<string, object> paraList);
    }
}
